import socket  
import time
import binascii
from hex import HexStrFromFile


if __name__ == '__main__':
    hexstr = HexStrFromFile('d:\\CDTFrame1.txt')
    frame = binascii.a2b_hex(hexstr)
    
    address = ('', 3150)
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # s = socket.socket()
    s.bind(address)
    s.listen(5)
    print 'server listen'
    
    while 1:
        ss, addr = s.accept()
        print 'got connected from',addr
        
        while 1:
            rs = ss.send(frame)
            now = time.localtime()
            print time.strftime('%Y-%m-%d %H:%M:%S'), 'send', rs
    
            time.sleep(180) 
    
        ss.close()
    s.close()
